import {ApiResponse, http as api, ListResponse, SearchKeyQueryParam} from "slash-admin";


export interface AuthTbDeptResponse {
    id: string,
    deptName: string,
    deptCode: string,
    fkParentDeptCode: string,
    fullDeptCode: string,
    fullDeptName: string,
    fkLeaderUserAccount: string,
    orderIndex: number,
    createTime: string,
    updateTime: string,
    createUserAccount: string,
    updateUserAccount: string,
}

export interface SelectAuthTbDeptPageListQueryParam extends SearchKeyQueryParam {

}

/**
 * 分页查询列表
 * @param query
 */
export const selectPageList = (query: SelectAuthTbDeptPageListQueryParam): Promise<ListResponse<AuthTbDeptResponse>> => {
    return api.doGet('/AuthApp/AuthTbDept/selectPageList', query)
}
/**
 * 根据ID查询
 * @param id
 */
export const selectById = (id: string | number): Promise<ApiResponse<AuthTbDeptResponse>> => {
    return api.doGet('/AuthApp/AuthTbDept/selectById', {id: id})
}

/**
 * 根据deptCode查询
 * @param deptCode
 */
export const selectByDeptCode = (deptCode: string): Promise<ApiResponse<AuthTbDeptResponse>> => {
    return api.doGet('/AuthApp/AuthTbDept/selectByDeptCode', {deptCode: deptCode})
}

/**
 * 新增
 * @param data
 */
export const doSaveEntity = (data: any): Promise<ApiResponse<boolean>> => {
    return api.doPost('/AuthApp/AuthTbDept/save', data)
}
/**
 * 实体
 * @param data
 */
export const doUpdateEntity = (data: any): Promise<ApiResponse<boolean>> => {
    return api.doPost('/AuthApp/AuthTbDept/update', data)
}
/**
 * 逻辑删除
 * @param id|ids
 */
export const doLogicDeleteEntity = (ids: Array<string | number> | number | string): Promise<ApiResponse<boolean>> => {
    let data: any = null;
    if (Array.isArray(ids)) {
        data = ids;
    } else {
        data = [ids];
    }
    return api.doPost('/AuthApp/AuthTbDept/logicDelete', data)
}
/**
 * 物理删除
 * @param id|ids
 */
export const doDeleteEntity = (ids: Array<string> | number | string): Promise<ApiResponse<boolean>> => {
    let data: any = null;
    if (Array.isArray(ids)) {
        data = ids;
    } else {
        data = [ids];
    }
    return api.doPost('/AuthApp/AuthTbDept/delete', data)
}
export const selectTreeList = async () => {

    return api.doGet('/AuthApp/AuthTbDept/selectTreeList')
}
export const doUpdateOrderIndex = async () => {

}
export default {
    doUpdateOrderIndex,
    selectPageList,
    selectTreeList,
    selectById,
    doDeleteEntity,
    doLogicDeleteEntity,
    doUpdateEntity,
    doSaveEntity,
    selectByDeptCode,
}
